package top.aicats.blog.BlogManage.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.aicats.blog.BlogManage.mapper.SubBlogTypeMapper;
import top.aicats.blog.BlogManage.model.BlogSubType;

import java.sql.Timestamp;
import java.util.List;
import java.util.UUID;

/**
 * @author sjc
 * @version 1.0
 * @date 2020/1/7 21:35
 * @email 952491025@qq.com
 */
@Service
public class SubBlogTypeImpl implements ISubBlogTypeService {

    @Autowired
    SubBlogTypeMapper subBlogTypeMapper;

    @Override
    public int addOneSubBlogType(BlogSubType type) {
        type.setBlogSubTypeRefid(UUID.randomUUID().toString().replaceAll("-", ""));
        type.setCreateTime(new Timestamp(System.currentTimeMillis()));
        return subBlogTypeMapper.insertOneSubType(type);
    }

    @Override
    public List<BlogSubType> getSubBlogTypeByMainRefid(BlogSubType type) {
        return subBlogTypeMapper.getSubBlogTypesByMainRefid(type);
    }

    @Override
    public int deleteSubType(BlogSubType type) {
        return subBlogTypeMapper.deleteSubTypeByRefid(type);
    }
}
